from flask import Blueprint
from service.course_service import (get_courses_by_teachername)
from service.user_service import (get_student_by_class_id)
from json import (dumps)

course = Blueprint("course", __name__, url_prefix="/course")


@course.route("/getCoursesByTeacherName/<name>", methods=("get", "post"))
def getcoursesbyteachername(name):
    courses_list = get_courses_by_teachername(name)
    return dumps(courses_list)


@course.route("/getMemberByClassId/<class_id>", methods=("get", "post"))
def get_member_by_class_id(class_id):
    return dumps(get_student_by_class_id(class_id))
